#include "MaterialViewer.h"

MaterialViewer::MaterialViewer(QWidget *parent, Qt::WindowFlags flags)
    : QDockWidget(tr("Material"), parent, flags)
{
    setObjectName(tr("Material"));
    //setGeometry(QRect(0, 0, 300, 400));
    //setMinimumSize(QSize(300, 400));

    QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    setSizePolicy(sizePolicy);

    mpContainer = new QWidget(this);
    mpContainer->setGeometry(QRect(0, 20, 256, 200));
    //mpContainer->setMinimumSize(QSize(300, 380));
    sizePolicy.setHeightForWidth(mpContainer->sizePolicy().hasHeightForWidth());
    mpContainer->setSizePolicy(sizePolicy);

    mpVerticalLayout = new QVBoxLayout(mpContainer);

    mpTreeWidget = new QTreeWidget(mpContainer);
    //mpTreeWidget->setGeometry(QRect(0, 0, 300, 380));
    //mpTreeWidget->setMinimumSize(QSize(300, 300));
    mpTreeWidget->setSortingEnabled(false);
    sizePolicy.setHeightForWidth(mpTreeWidget->sizePolicy().hasHeightForWidth());
    mpTreeWidget->setSizePolicy(sizePolicy);

    QTreeWidgetItem *headerItem = mpTreeWidget->headerItem();
    headerItem->setText(0, QApplication::translate("Form", "Property", 0, QApplication::UnicodeUTF8));
    headerItem->setText(1, QApplication::translate("Form", "Value", 0, QApplication::UnicodeUTF8));

    mpAmbientItem = new QTreeWidgetItem(mpTreeWidget);
    mpAmbientItem->setText(0, QApplication::translate("Form", "Ambient", 0, QApplication::UnicodeUTF8));
    mpDiffuseItem = new QTreeWidgetItem(mpTreeWidget);
    mpDiffuseItem->setText(0, QApplication::translate("Form", "Diffuse", 0, QApplication::UnicodeUTF8));
    mpSpecularItem = new QTreeWidgetItem(mpTreeWidget);
    mpSpecularItem->setText(0, QApplication::translate("Form", "Specular", 0, QApplication::UnicodeUTF8));
    mpEmissionItem = new QTreeWidgetItem(mpTreeWidget);
    mpEmissionItem->setText(0, QApplication::translate("Form", "Emission", 0, QApplication::UnicodeUTF8));

    mpShininessItem = new QTreeWidgetItem(mpTreeWidget);
    mpShininessItem->setText(0, QApplication::translate("Form", "Shininess", 0, QApplication::UnicodeUTF8));
    mpShininess = new QDoubleSpinBox(this);
    mpShininess->setRange(0.0f, 128.0f);
    mpShininess->setDecimals(6);
    mpTreeWidget->setItemWidget(mpShininessItem, 1, mpShininess);

    mpColorMaterialItem = new QTreeWidgetItem(mpTreeWidget);
    mpColorMaterialItem->setText(0, QApplication::translate("Form", "ColorMaterial", 0, QApplication::UnicodeUTF8));
    mpColorMaterial = new QCheckBox(this);
    mpTreeWidget->setItemWidget(mpColorMaterialItem, 1, mpColorMaterial);

    mpLightReceiveItem = new QTreeWidgetItem(mpTreeWidget);
    mpLightReceiveItem->setText(0, QApplication::translate("Form", "LightReceive", 0, QApplication::UnicodeUTF8));
    mpLightReceive = new QCheckBox(this);
    mpTreeWidget->setItemWidget(mpLightReceiveItem, 1, mpLightReceive);

    mpShadowCastItem = new QTreeWidgetItem(mpTreeWidget);
    mpShadowCastItem->setText(0, QApplication::translate("Form", "ShadowCast", 0, QApplication::UnicodeUTF8));
    mpShadowCast = new QCheckBox(this);
    mpTreeWidget->setItemWidget(mpShadowCastItem, 1, mpShadowCast);

    mpShadowReceiveItem = new QTreeWidgetItem(mpTreeWidget);
    mpShadowReceiveItem->setText(0, QApplication::translate("Form", "ShadowReceive", 0, QApplication::UnicodeUTF8));
    mpShadowReceive = new QCheckBox(this);
    mpTreeWidget->setItemWidget(mpShadowReceiveItem, 1, mpShadowReceive);

    mpVerticalLayout->addWidget(mpTreeWidget);
}

MaterialViewer::~MaterialViewer()
{
}
